import ajax from "../utils/request";

// 获取购物车的数据
export function getCart(data: {userid: string}){
  return ajax({
    url: '/cart/list',
    data,
    method: 'post'
  })
}

// 添加购物车
export function setCart(data: {userid: string,proid: string,num: number}){
  return ajax({
    url: '/cart/add',
    data,
    method: 'post'
  })
}

// 更新购物车数量的接口
export function updateNum(data: {cartid: string,num: number}){
  return ajax({
    url: '/cart/updatenum',
    data,
    method: 'post'
  })
}

// 修改购物车选中状态的接口
export function selectCart(data: {cartid: string,flag: boolean}){
  return ajax({
    url: '/cart/selectone',
    data,
    method: 'post'
  })
}

// 删除单条购物车的接口
export function delCart(data: {cartid: string}){
  return ajax({
    url: '/cart/remove',
    data,
    method: 'post'
  })
}


// 全选和取消全选
export function selectAll(data: {userid: string, type: boolean}){
  return ajax({
    url: '/cart/selectall',
    data,
    method: 'post'
  })
}

